package com.example.async_demo.service.impl;

import com.example.async_demo.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * <P> @Author: SongKeCheng
 * <P> Type: Class
 * <P> Description:
 * <P> Date: 2024/6/4:9:17
 */

@SuppressWarnings({"unchecked", ""})
@Service
public class UserServiceImpl implements UserService {
    private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class);

    @Override
    public void addUser() {
        log.info("增加用户成功");
    }

    @Override
    public void addLog() {
        timeSleep(2);
        log.info("新增日志记录");
    }

    @Override
    public void addAsyncLog() {
        timeSleep(2);
        log.info("新增日志记录");
    }


    private static void timeSleep(Integer seconds) {
        try {
            TimeUnit.SECONDS.sleep(seconds);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
